home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 2 / CU Amiga Magazine's Super CD-ROM 02 (1996)(EMAP Images)(GB)[!][issue 1996-04].iso / magazine / amiga_e / e_update_v3.2e / easygui / plugin_test.e < prev   
Text File  |  1994-11-08  |  2KB  |  61 lines

  1. -> sample plugins.
  2.  
  3. OPT OSVERSION=37
  4. MODULE 'tools/EasyGUI', 'tools/exceptions', 'intuition/intuition'
  5.  
  6. -> a very simple plugin. renders scalable gfx, and lets the user interact :-)
  7.  
  8. OBJECT myplugin OF plugin
  9.   xm:INT,ym:INT
  10. ENDOBJECT
  11.  
  12. PROC min_size(fh) OF myplugin IS 100,100
  13.  
  14. PROC render(x,y,xs,ys,w) OF myplugin IS self.draw(w)
  15.  
  16. PROC message_test(imsg:PTR TO intuimessage,win:PTR TO window) OF myplugin
  17.   DEF x,y
  18.   IF (imsg.class=IDCMP_MOUSEBUTTONS) AND (imsg.code=SELECTUP)
  19.     x:=imsg.mousex
  20.     y:=imsg.mousey
  21.     IF (x>=self.x) AND (y>=self.y) AND (x<(self.x+self.xs)) AND (y<(self.y+self.ys))
  22.       self.xm:=x-self.x*1000/self.xs    -> scale
  23.       self.ym:=y-self.y*1000/self.ys
  24.       RETURN TRUE
  25.     ENDIF
  26.   ENDIF
  27. ENDPROC FALSE
  28.  
  29. PROC message_action(win:PTR TO window) OF myplugin
  30.   self.draw(win)
  31. ENDPROC FALSE
  32.  
  33. PROC draw(win:PTR TO window) OF myplugin
  34.   DEF xm,ym,a,b=0
  35.   xm:=self.xm*self.xs/1000+self.x    -> scale back
  36.   ym:=self.ym*self.ys/1000+self.y
  37.   SetStdRast(win.rport)
  38.   Box(self.x,self.y,self.x+self.xs-1,self.y+self.ys-1,2)
  39.   FOR a:=self.x TO self.x+self.xs-1
  40.     Line(a,self.y,xm,ym,b++)
  41.     Line(a,self.y+self.ys-1,xm,ym,b)
  42.   ENDFOR
  43. ENDPROC
  44.  
  45. -> now use our plugin
  46.  
  47. PROC main() HANDLE
  48.   DEF p:PTR TO plugin,mp:PTR TO myplugin
  49.   easygui('those damn handy plugins...',
  50.     [ROWS,
  51.       [TEXT,'just the default plugin:',NIL,TRUE,15],
  52.       [BEVEL,[PLUGIN,0,NEW p]],
  53.       [TEXT,'our own plugin (try mouse):',NIL,TRUE,15],
  54.       [BEVEL,[PLUGIN,0,NEW mp]],
  55.       [SBUTTON,0,'yeah, ok']
  56.     ]
  57.   )
  58. EXCEPT
  59.   report_exception()
  60. ENDPROC
  61.